package com.fzg.common.demo.hutool;

import cn.hutool.core.util.*;
import lombok.extern.slf4j.Slf4j;

import java.math.BigDecimal;
import java.net.URL;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;

/**
 * create by fzg
 * 2022/12/12 11:07
 */

@Slf4j
public class Demo06 {

    public static void main(String[] args) {
//        int wb = HashUtil.additiveHash("wb", 2);
//        log.info(wb + "");
//        int c = HashUtil.jsHash("这是一个");
//        log.info(c + "");


        int[] ints = PageUtil.transToStartEnd(3, 5);
        log.info(Arrays.toString(ints));

        // 根据总数计算总页数
        int page = PageUtil.totalPage(30, 3);
        log.info("一共有{}页",page);
        int[] rainbow = PageUtil.rainbow(5, 20, 6);
        log.info(Arrays.toString(rainbow));

        String ipconfig = RuntimeUtil.execForStr("ipconfig");
        log.info(ipconfig);

        int c = RandomUtil.randomInt(0,10);
        log.info("随机数为：{}",c);


        double a = NumberUtil.add(1, 2);
        log.info(a + "");

        double sub = NumberUtil.sub(90, 70);
        log.info(sub + "");

        double mul = NumberUtil.mul(2, 3);
        log.info(mul + "");

        double div = NumberUtil.div(3, 9);
        log.info(div + "");

        BigDecimal round = NumberUtil.round(12.3487538292, 3);
        log.info(round + "");

        String s = NumberUtil.roundStr(0.232, 2);
        log.info(s + "");

        String s1 = NumberUtil.decimalFormat(",###", 10124555);
        log.info(s1);

        boolean de = NumberUtil.isNumber("de");
        boolean validNumber = NumberUtil.isValidNumber(8);
        log.info(validNumber + "");
        log.info(de + "");

        boolean integer = NumberUtil.isInteger("1");
        log.info(integer + "");

        boolean s2 = NumberUtil.isInteger("s");
        log.info(s2 + "");

        boolean aDouble = NumberUtil.isDouble("2.28");
        log.info(aDouble + "");

        boolean aDouble1 = NumberUtil.isDouble("2.3fjd");
        log.info(aDouble1 + "");

        boolean primes = NumberUtil.isPrimes(2);
        log.info(primes + "");

        boolean primes1 = NumberUtil.isPrimes(4);
        log.info(primes1 + "");

        int[] ints1 = NumberUtil.generateRandomNumber(0, 5, 5);
        for (int i : ints1) {
            log.info(i + "");
        }

        Integer[] integers = NumberUtil.generateBySet(1, 4, 3);
        for (Integer integer1 : integers) {
            log.info(integer1.toString());
        }

        long factorial = NumberUtil.factorial(3);
        log.info(factorial + "");

        log.info("#####################################");
        int[] range = NumberUtil.range(1, 100,5);
        ArrayList<Integer> list = new ArrayList<>();
        for (int i : range) {
            list.add(i);
            log.info(i + "");
        }

        Collection<Integer> integers1 = NumberUtil.appendRange(1, 4, 1, list);
        for (Integer integer1 : integers1) {
            log.info(integer1 + "");
        }

        log.info("#########################################################");
        boolean empty = ArrayUtil.isEmpty(new char[]{});
        log.info(empty + "");
        int[] a1 = null;
        boolean empty1 = ArrayUtil.isEmpty(a1);
        log.info(empty1 + "");

        log.info("#########################################################");
        String s3 = RandomUtil.randomString(5);
        log.info(s3);


        URL url = URLUtil.url("https://www.hutool.cn/docs/index.html#/core/%E5%B7%A5%E5%85%B7%E7%B1%BB/URL%E5%B7%A5%E5%85%B7-URLUtil?id=%e6%96%b9%e6%b3%95");
        String normalize = URLUtil.normalize("https://www.hutool.cn/docs/index.html#/core/%E5%B7%A5%E5%85%B7%E7%B1%BB/URL%E5%B7%A5%E5%85%B7-URLUtil?id=%e6%96%b9%e6%b3%95");
        log.info(normalize);

    }

}
